package com.woniuxy.receiver;

import com.woniuxy.entity.Product;
import com.woniuxy.sender.ProductSender;
import com.woniuxy.service.ProductService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: 曾令忠
 * @Description:
 * @Date: 2020/7/6 0006-上午 10:51
 */
@Component
public class ProductReceiver {
    @Autowired
    ProductService productService;
    @Autowired
    ProductSender productSender;

    @RabbitListener(queues = "rpc_queue_a")
    public void recevie(int pid){
        System.out.println("接收到商品ID："+pid);
        Product product = productService.findProductyId(pid);
        System.out.println(product);
        //把数据发送到用户模块
        productSender.send(product);

    }
}
